home *** CD-ROM | disk | FTP | other *** search
- Path: compassnet.com!usenet
- From: smelly@e-tex.com
- Newsgroups: comp.lang.c
- Subject: Re: Newbie question: Is this code OK?
- Date: Wed, 17 Jan 1996 23:29:44 -0600
- Organization: Compass Net, Inc.
- Message-ID: <30FDDAC8.D79@e-tex.com>
- References: <4di986$fk1@pegasus.interpac.net>
- NNTP-Posting-Host: 206.25.37.101
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (Win95; I)
-
- > Do I need the empty {} after a for loop that has no body? I assumed >
- > if I didn't, the loop would execute the next statement after it.
-
-
- > for (; i<length, ((string[i]!='\n') &&
- > (string[i]!='\t') &&
- > (string[i]!=' ')); i++)
- > /* and skip past any other */
- > /* chars that may be there */
- > { } /* loop does all work, nothing inside body */
-
- I am also new to C programming; however, I think I can make one
- suggestion. Since your second for loop does all the work and you don't
- need a body, you can write it like this.
-
- for ( ; i<length, ((string[i]!='\n') &&
- (string[i]!='\t') &&
- (string[i]!=' ')); i++);
-
- Placing the semi-colon at the end of the loop will prevent it from
- running the next statement following the loop until after it has
- processed to a point where the condition if false. I believe this will
- work. Good luck and have fun! :-)
-
- smelly@e-tex.com
- Smelly Dog
-